package lv.dysnomia.portal.web;

import javax.servlet.http.{HttpServlet,HttpServletRequest,HttpServletResponse}

import com.google.appengine.api.users.{User,UserService,UserServiceFactory}

class GuestbookServlet extends HttpServlet {
    override def doGet(request:HttpServletRequest, response:HttpServletResponse) = {              
        val userService = UserServiceFactory getUserService
        val user = userService getCurrentUser

        if (user != null) {
            response setContentType "text/plain"
            (response getWriter) println "Hello, " + user.getNickname
        } else {
            response sendRedirect (userService createLoginURL (request getRequestURI))
        }
    }
}